/*
 * io.c
 *
 * Copyright 2011 Pieter Agten
 *
 * This file is part of Yarf.
 *
 * Yarf is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Yarf is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Yarf.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @file   io.c
 * @author Pieter Agten (pieter.agten@gmail.com)
 * @date   21 sep 2011
 * @brief  Initialization of digital I/O pins
 */

#include "io.h"

#include "yarf.h"
#include "fastio.h"
#include "steppers.h"

void
io_init(void)
{
  SET_OUTPUT(X_ENABLE_PIN);
  SET_OUTPUT(X_STEP_PIN);
  SET_OUTPUT(X_DIR_PIN);

  SET_OUTPUT(Y_ENABLE_PIN);
  SET_OUTPUT(Y_STEP_PIN);
  SET_OUTPUT(Y_DIR_PIN);

  SET_OUTPUT(Z_ENABLE_PIN);
  SET_OUTPUT(Z_STEP_PIN);
  SET_OUTPUT(Z_DIR_PIN);

  SET_OUTPUT(E_ENABLE_PIN);
  SET_OUTPUT(E_STEP_PIN);
  SET_OUTPUT(E_DIR_PIN);

  SET_INPUT(X_MIN_PIN);
  SET_INPUT(Y_MIN_PIN);
  SET_INPUT(Z_MIN_PIN);

#if X_MAX_PIN >= 0
  SET_INPUT(X_MAX_PIN);
#endif
#if Y_MAX_PIN >= 0
  SET_INPUT(Y_MAX_PIN);
#endif
#if Z_MAX_PIN >= 0
  SET_INPUT(Z_MAX_PIN);
#endif

  SET_OUTPUT(HEAT1_PIN);
  SET_OUTPUT(HEAT2_PIN);

  /* Disable all stepper motors */
  steppers_disable();
}


